//index.js
//获取应用实例
var utl = require('../../utils/util.js');
const app = getApp()

Page({
  data: {
    indicatorDots: true,
    autplay:false,
    imgUrls: ['/pages/images/banner3.png'],
    hotUrls: ['/pages/images/banner_activity.png', '/pages/images/banner_activity1.png']
  },
  //事件处理函数
  bindViewTap: function() {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  onLoad: function () {
    this.checkActive();
    this.queryhotActivety();
    this.querymerch();
  },
  //查询banner
  checkActive:function(){
    utl.httServer('/banner/list', {}, (err, res) => {
      if (err) {
        wx.showToast({
          title: err,
          icon: 'none',
          duration: 2000
        })
        return;
      }
      var rd = res.data;
      this.setData({
        imgUrls:rd
      })
    })
  },
  //热门活动
  queryhotActivety:function(){
    utl.httServer('/activity/list', {}, (err, res) => {
      if (err) {
        wx.showToast({
          title: err,
          icon: 'none',
          duration: 2000
        })
        return;
      }
      var rd = res.data;
      this.setData({
        hotUrls: rd
      })
    })
  },
  //热门商户
  querymerch:function(){
    utl.httServer('/merchant/query_hot_merchant', { 'key': '12121', 'parentNo': '','sign': '121212', "roundNo": '1212'}, (err, res) => {
      if (err) {
        wx.showToast({
          title: err,
          icon: 'none',
          duration: 2000
        })
        return;
      }
      var rd = res.data;
      this.setData({
        
      })
    })
  },
  getUserInfo: function(e) {
    console.log(e)
    app.globalData.userInfo = e.detail.userInfo
    this.setData({
      userInfo: e.detail.userInfo,
      hasUserInfo: true
    })
  },
  jumpshop:function(){
    wx.navigateTo({
      url: '/pages/merch/index',
    })
  },
  serachAction:function(){
    wx.navigateTo({
      url: '/pages/serch/index',
    })
  }
})
